let currentSlide = 0;
const slides = document.querySelectorAll('.carousel-images img');
const totalSlides = slides.length;

function showSlide(index) {
  slides.forEach((slide, i) => {
    slide.classList.remove('active');
    if (i === index) {
      slide.classList.add('active');
    }
  });
}

function moveSlide(step) {
  currentSlide = (currentSlide + step + totalSlides) % totalSlides;
  showSlide(currentSlide);
}

// 初始化轮播图
showSlide(currentSlide);

// 设置自动播放
setInterval(() => {
  moveSlide(1);
}, 3000); // 每3秒切换一次图片
// 清除定时器,停止自动播放
function stopAutoPlay(){
	if(timer){
       clearInterval(timer);
	}
}
